<!DOCTYPE HTML>
<html lang="en">


<head>
    <meta charset="utf-8">
    <meta name="keywords" content="1.EnvironmentConfiguration, Hexo">
    <meta name="description" content="
基本环境配置
1. 检查nvcc
2. 安装torch和vision（可忽略）


jetson nao其他配置
1. 更新镜像源
1.1. apt
1.2. pip
1.3. docker


2. 安装pytorch和torchvis">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
    <meta name="renderer" content="webkit|ie-stand|ie-comp">
    <meta name="mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
    <meta name="referrer" content="no-referrer-when-downgrade">
    <!-- Global site tag (gtag.js) - Google Analytics -->


    <title>1.EnvironmentConfiguration | Hexo</title>
    <link rel="icon" type="image/png" href="/favicon.png">
    


    <!-- bg-cover style     -->



<link rel="stylesheet" type="text/css" href="/libs/awesome/css/all.min.css">
<link rel="stylesheet" type="text/css" href="/libs/materialize/materialize.min.css">
<link rel="stylesheet" type="text/css" href="/libs/aos/aos.css">
<link rel="stylesheet" type="text/css" href="/libs/animate/animate.min.css">
<link rel="stylesheet" type="text/css" href="/libs/lightGallery/css/lightgallery.min.css">
<link rel="stylesheet" type="text/css" href="/css/matery.css">
<link rel="stylesheet" type="text/css" href="/css/my.css">
<link rel="stylesheet" type="text/css" href="/css/dark.css" media="none" onload="if(media!='all')media='all'">




    <link rel="stylesheet" href="/libs/tocbot/tocbot.css">
    <link rel="stylesheet" href="/css/post.css">




    
        <link rel="stylesheet" type="text/css" href="/css/reward.css">
    



    <script src="/libs/jquery/jquery-3.6.0.min.js"></script>

<meta name="generator" content="Hexo 7.1.1"></head>


<body>
    <header class="navbar-fixed">
    <nav id="headNav" class="bg-color nav-transparent">
        <div id="navContainer" class="nav-wrapper container">
            <div class="brand-logo">
                <a href="/" class="waves-effect waves-light">
                    
                    <img src="/medias/logo.png" class="logo-img" alt="LOGO">
                    
                    <span class="logo-span">Hexo</span>
                </a>
            </div>
            

<a href="#" data-target="mobile-nav" class="sidenav-trigger button-collapse"><i class="fas fa-bars"></i></a>
<ul class="right nav-menu">
  
  <li class="hide-on-med-and-down nav-item">
    
    <a href="/" class="waves-effect waves-light">
      
      <i class="fas fa-home" style="zoom: 0.6;"></i>
      
      <span>Index</span>
    </a>
    
  </li>
  
  <li class="hide-on-med-and-down nav-item">
    
    <a href="/tags" class="waves-effect waves-light">
      
      <i class="fas fa-tags" style="zoom: 0.6;"></i>
      
      <span>Tags</span>
    </a>
    
  </li>
  
  <li class="hide-on-med-and-down nav-item">
    
    <a href="/categories" class="waves-effect waves-light">
      
      <i class="fas fa-bookmark" style="zoom: 0.6;"></i>
      
      <span>Categories</span>
    </a>
    
  </li>
  
  <li class="hide-on-med-and-down nav-item">
    
    <a href="/archives" class="waves-effect waves-light">
      
      <i class="fas fa-archive" style="zoom: 0.6;"></i>
      
      <span>Archives</span>
    </a>
    
  </li>
  
  <li class="hide-on-med-and-down nav-item">
    
    <a href="/about" class="waves-effect waves-light">
      
      <i class="fas fa-user-circle" style="zoom: 0.6;"></i>
      
      <span>About</span>
    </a>
    
  </li>
  
  <li class="hide-on-med-and-down nav-item">
    
    <a href="/contact" class="waves-effect waves-light">
      
      <i class="fas fa-comments" style="zoom: 0.6;"></i>
      
      <span>Contact</span>
    </a>
    
  </li>
  
  <li class="hide-on-med-and-down nav-item">
    
    <a href="/friends" class="waves-effect waves-light">
      
      <i class="fas fa-address-book" style="zoom: 0.6;"></i>
      
      <span>Friends</span>
    </a>
    
  </li>
  
  <li>
    <a href="#searchModal" class="modal-trigger waves-effect waves-light">
      <i id="searchIcon" class="fas fa-search" title="Search" style="zoom: 0.85;"></i>
    </a>
  </li>
  <li>
    <a href="javascript:;" class="waves-effect waves-light" onclick="switchNightMode()" title="深色/浅色模式" >
      <i id="sum-moon-icon" class="fas fa-sun" style="zoom: 0.85;"></i>
    </a>
  </li>
</ul>


<div id="mobile-nav" class="side-nav sidenav">

    <div class="mobile-head bg-color">
        
        <img src="/medias/logo.png" class="logo-img circle responsive-img">
        
        <div class="logo-name">Hexo</div>
        <div class="logo-desc">
            
            Never really desperate, only the lost of the soul.
            
        </div>
    </div>

    <ul class="menu-list mobile-menu-list">
        
        <li class="m-nav-item">
	  
		<a href="/" class="waves-effect waves-light">
			
			    <i class="fa-fw fas fa-home"></i>
			
			Index
		</a>
          
        </li>
        
        <li class="m-nav-item">
	  
		<a href="/tags" class="waves-effect waves-light">
			
			    <i class="fa-fw fas fa-tags"></i>
			
			Tags
		</a>
          
        </li>
        
        <li class="m-nav-item">
	  
		<a href="/categories" class="waves-effect waves-light">
			
			    <i class="fa-fw fas fa-bookmark"></i>
			
			Categories
		</a>
          
        </li>
        
        <li class="m-nav-item">
	  
		<a href="/archives" class="waves-effect waves-light">
			
			    <i class="fa-fw fas fa-archive"></i>
			
			Archives
		</a>
          
        </li>
        
        <li class="m-nav-item">
	  
		<a href="/about" class="waves-effect waves-light">
			
			    <i class="fa-fw fas fa-user-circle"></i>
			
			About
		</a>
          
        </li>
        
        <li class="m-nav-item">
	  
		<a href="/contact" class="waves-effect waves-light">
			
			    <i class="fa-fw fas fa-comments"></i>
			
			Contact
		</a>
          
        </li>
        
        <li class="m-nav-item">
	  
		<a href="/friends" class="waves-effect waves-light">
			
			    <i class="fa-fw fas fa-address-book"></i>
			
			Friends
		</a>
          
        </li>
        
        
        <li><div class="divider"></div></li>
        <li>
            <a href="https://github.com/blinkfox/hexo-theme-matery" class="waves-effect waves-light" target="_blank">
                <i class="fab fa-github-square fa-fw"></i>Fork Me
            </a>
        </li>
        
    </ul>
</div>


        </div>

        
            <style>
    .nav-transparent .github-corner {
        display: none !important;
    }

    .github-corner {
        position: absolute;
        z-index: 10;
        top: 0;
        right: 0;
        border: 0;
        transform: scale(1.1);
    }

    .github-corner svg {
        color: #0f9d58;
        fill: #fff;
        height: 64px;
        width: 64px;
    }

    .github-corner:hover .octo-arm {
        animation: a 0.56s ease-in-out;
    }

    .github-corner .octo-arm {
        animation: none;
    }

    @keyframes a {
        0%,
        to {
            transform: rotate(0);
        }
        20%,
        60% {
            transform: rotate(-25deg);
        }
        40%,
        80% {
            transform: rotate(10deg);
        }
    }
</style>

<a href="https://github.com/blinkfox/hexo-theme-matery" class="github-corner tooltipped hide-on-med-and-down" target="_blank"
   data-tooltip="Fork Me" data-position="left" data-delay="50">
    <svg viewBox="0 0 250 250" aria-hidden="true">
        <path d="M0,0 L115,115 L130,115 L142,142 L250,250 L250,0 Z"></path>
        <path d="M128.3,109.0 C113.8,99.7 119.0,89.6 119.0,89.6 C122.0,82.7 120.5,78.6 120.5,78.6 C119.2,72.0 123.4,76.3 123.4,76.3 C127.3,80.9 125.5,87.3 125.5,87.3 C122.9,97.6 130.6,101.9 134.4,103.2"
              fill="currentColor" style="transform-origin: 130px 106px;" class="octo-arm"></path>
        <path d="M115.0,115.0 C114.9,115.1 118.7,116.5 119.8,115.4 L133.7,101.6 C136.9,99.2 139.9,98.4 142.2,98.6 C133.8,88.0 127.5,74.4 143.8,58.0 C148.5,53.4 154.0,51.2 159.7,51.0 C160.3,49.4 163.2,43.6 171.4,40.1 C171.4,40.1 176.1,42.5 178.8,56.2 C183.1,58.6 187.2,61.8 190.9,65.4 C194.5,69.0 197.7,73.2 200.1,77.6 C213.8,80.2 216.3,84.9 216.3,84.9 C212.7,93.1 206.9,96.0 205.4,96.6 C205.1,102.4 203.0,107.8 198.3,112.5 C181.9,128.9 168.3,122.5 157.7,114.1 C157.9,116.9 156.7,120.9 152.7,124.9 L141.0,136.5 C139.8,137.7 141.6,141.9 141.8,141.8 Z"
              fill="currentColor" class="octo-body"></path>
    </svg>
</a>
        
    </nav>

</header>

    



<div class="bg-cover pd-header post-cover" style="background-image: url('/medias/featureimages/0.jpg')">
    <div class="container" style="right: 0px;left: 0px;">
        <div class="row">
            <div class="col s12 m12 l12">
                <div class="brand">
                    <h1 class="description center-align post-title">1.EnvironmentConfiguration</h1>
                </div>
            </div>
        </div>
    </div>
</div>




<main class="post-container content">

    
    <div class="row">
    <div id="main-content" class="col s12 m12 l9">
        <!-- 文章内容详情 -->
<div id="artDetail">
    <div class="card">
        <div class="card-content article-info">
            <div class="row tag-cate">
                <div class="col s7">
                    
                          <div class="article-tag">
                            <span class="chip bg-color">No tag</span>
                          </div>
                    
                </div>
                <div class="col s5 right-align">
                    
                </div>
            </div>

            <div class="post-info">
                
                <div class="post-date info-break-policy">
                    <i class="far fa-calendar-minus fa-fw"></i>Publish Date:&nbsp;&nbsp;
                    2024-02-13
                </div>
                

                

                

                

                
            </div>
        </div>
        <hr class="clearfix">

        

        

        <div class="card-content article-card-content">
            <div id="articleContent">
                <ul>
<li><a href="#%E5%9F%BA%E6%9C%AC%E7%8E%AF%E5%A2%83%E9%85%8D%E7%BD%AE">基本环境配置</a><ul>
<li><a href="#1-%E6%A3%80%E6%9F%A5nvcc">1. 检查nvcc</a></li>
<li><a href="#2-%E5%AE%89%E8%A3%85torch%E5%92%8Cvision%E5%8F%AF%E5%BF%BD%E7%95%A5">2. 安装torch和vision（可忽略）</a></li>
</ul>
</li>
<li><a href="#jetson-nao%E5%85%B6%E4%BB%96%E9%85%8D%E7%BD%AE">jetson nao其他配置</a><ul>
<li><a href="#1-%E6%9B%B4%E6%96%B0%E9%95%9C%E5%83%8F%E6%BA%90">1. 更新镜像源</a><ul>
<li><a href="#11-apt">1.1. apt</a></li>
<li><a href="#12-pip">1.2. pip</a></li>
<li><a href="#13-docker">1.3. docker</a></li>
</ul>
</li>
<li><a href="#2-%E5%AE%89%E8%A3%85pytorch%E5%92%8Ctorchvison">2. 安装pytorch和torchvison</a></li>
<li><a href="#3-miniforge%E5%8C%85%E7%AE%A1%E7%90%86%E9%80%89">3. miniforge包管理(选)</a><ul>
<li><a href="#31-miniforge%E7%AE%80%E4%BB%8B">3.1. miniforge简介</a></li>
<li><a href="#32-%E5%AE%89%E8%A3%85miniforge">3.2. 安装miniforge</a></li>
<li><a href="#33-%E5%AE%89%E8%A3%85pytorchtorchvision">3.3. 安装pytorch、torchvision</a></li>
<li><a href="#34-%E5%AE%89%E8%A3%85%E6%96%B0%E7%9A%84%E8%99%9A%E6%8B%9F%E7%8E%AF%E5%A2%83">3.4. 安装新的虚拟环境</a></li>
<li><a href="#35-pytorch18">3.5. pytorch1.8</a></li>
<li><a href="#36-orchvision-v090">3.6. orchvision v0.9.0</a></li>
</ul>
</li>
<li><a href="#4-%E6%9F%A5%E7%9C%8Bjetson%E4%BF%A1%E6%81%AF-jtop">4. 查看jetson信息 （jtop）</a></li>
<li><a href="#5-%E9%A3%8E%E6%89%87%E8%87%AA%E5%8A%A8%E6%8E%A7%E5%88%B6">5. 风扇自动控制</a></li>
<li><a href="#6-%E5%A2%9E%E5%8A%A0swap%E5%88%86%E5%8C%BA%E5%A4%A7%E5%B0%8F">6. 增加Swap分区大小</a></li>
<li><a href="#7-nomachine%E8%99%9A%E6%8B%9F%E7%BD%91%E7%BB%9C%E6%8E%A7%E5%88%B6%E5%8F%B0">7. nomachine（虚拟网络控制台）</a></li>
<li><a href="#8-vnc%E8%99%9A%E6%8B%9F%E7%BD%91%E7%BB%9C%E6%8E%A7%E5%88%B6%E5%8F%B0">8. VNC（虚拟网络控制台）</a></li>
<li><a href="#9-tensort">9. TensoRT</a><ul>
<li><a href="#91-tensort%E4%BB%8B%E7%BB%8D">9.1. TensoRT介绍：</a></li>
<li><a href="#92-%E6%A3%80%E6%9F%A5%E8%87%AA%E5%B8%A6tensorrt%E7%8E%AF%E5%A2%83%E9%80%89">9.2. 检查自带TensorRT环境（选）</a></li>
<li><a href="#93-jetson-inference%E5%BA%93%E5%AE%89%E8%A3%85%E9%80%89">9.3. jetson inference库安装（选）</a></li>
</ul>
</li>
<li><a href="#10-%E5%AE%89%E8%A3%85jupyter%E5%92%8Cjetcam">10. 安装jupyter和jetcam</a></li>
<li><a href="#11-darknet%E6%A1%86%E6%9E%B6%E9%80%89">11. darknet框架（选）</a></li>
</ul>
</li>
<li><a href="#nvidia-jetson-nano-%E5%AE%89%E8%A3%85-gstreamer">Nvidia Jetson Nano 安装 GStreamer</a><ul>
<li><a href="#1-%E9%85%8D%E7%BD%AEgstreamer%E7%AE%A1%E9%81%93">1. 配置GStreamer管道</a></li>
</ul>
</li>
</ul>
<h1 id="基本环境配置"><a href="#基本环境配置" class="headerlink" title="基本环境配置"></a>基本环境配置</h1><h2 id="1-检查nvcc"><a href="#1-检查nvcc" class="headerlink" title="1. 检查nvcc"></a>1. 检查nvcc</h2><p>jetson nano是原装了CUDA的，但是需要用户导入环境变量（导入相关的路径）才可以使用，<strong>只有环境变量导入成功后</strong>，方可在命令行使用 <code>nvcc -V</code></p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">sudo vim .bashrc</span><br></pre></td></tr></table></figure>

<p>在最后添加这三行</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">#选择一个即可</span></span><br><span class="line"></span><br><span class="line"><span class="built_in">export</span> CUDA_HOME=<span class="variable">$CUDA_HOME</span>:/usr/local/cuda</span><br><span class="line"><span class="built_in">export</span> LD_LIBRARY_PATH=/usr/local/cuda/lib64:<span class="variable">$LD_LIBRARY_PATH</span></span><br><span class="line"><span class="built_in">export</span> PATH=/usr/local/cuda/bin:<span class="variable">$PATH</span></span><br><span class="line"></span><br><span class="line"></span><br><span class="line"><span class="built_in">export</span> PATH=/usr/local/cuda-10.2/bin<span class="variable">$&#123;PATH:+:<span class="variable">$&#123;PATH&#125;</span>&#125;</span></span><br><span class="line"><span class="built_in">export</span> LD_LIBRARY_PATH=/usr/local/cuda-10.2/lib64\</span><br><span class="line"><span class="variable">$&#123;LD_LIBRARY_PATH:+:<span class="variable">$&#123;LD_LIBRARY_PATH&#125;</span>&#125;</span></span><br><span class="line"></span><br></pre></td></tr></table></figure>

<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">保存后退出，执行 <span class="built_in">source</span> ~/.bashrc，使得环境变量生效。</span><br></pre></td></tr></table></figure>

<p>在命令行输入 <code>nvcc -V</code> 如果正常输出，说明CUDA路径配置成功</p>
<img src="https://yqypicbed.oss-cn-hangzhou.aliyuncs.com/typoraoss/image-20220225161019891.png" alt="image-20220225161019891" style="zoom:50%;" />



<h2 id="2-安装torch和vision（可忽略）"><a href="#2-安装torch和vision（可忽略）" class="headerlink" title="2. 安装torch和vision（可忽略）"></a>2. 安装torch和vision（可忽略）</h2><ul>
<li><a target="_blank" rel="noopener" href="https://forums.developer.nvidia.com/t/pytorch-for-jetson-version-1-9-0-now-available/72048">官网</a></li>
</ul>
<p><a target="_blank" rel="noopener" href="https://blog.csdn.net/weixin_43947712/article/details/115530913">参考资料</a></p>
<p>安装好后测试如图：</p>
<p><img src="https://yqypicbed.oss-cn-hangzhou.aliyuncs.com/typoraoss/image-20220223224621637.png" alt="image-20220223224621637"></p>
<p>安装pytorch，首先CUDA的步骤得过一下可以看到nvcc -V</p>
<p>安装pytorch跟CUDA的版本要对应</p>
<img src="https://img2020.cnblogs.com/blog/1733978/202104/1733978-20210414172645876-1962676.png" alt="img" style="zoom: 67%;" width="1000"/>

<p>网上找了个1.6.0的安装包通过winscp上传到jetson后离线安装下，该离线包可以到资料5、常用库和模型中获取</p>
<p>sudo pip3 install torch-1.6.0a0+b31f58d-cp36-cp36m-linux_aarch64.whl</p>
<p>sudo pip3 install torchvision</p>
<p>sudo pip install boto3</p>
<p>终端输入python3进入到python3的运行环境中测试下，import torch，我遇到的报错是ImportError:libopenblas.so.0:无法打开共享对象文件或目录，看了下这个教程:<a target="_blank" rel="noopener" href="https://www.cnpython.com/qa/77454">https://www.cnpython.com/qa/77454</a></p>
<p>尝试安装了OpenBlas系统库问题解决了</p>
<p>sudo apt-get install libopenblas-dev</p>
<p>到python环境中</p>
<p>import torch</p>
<p>print(torch.<strong>version</strong>)</p>
<p>查看安装的版本</p>
<img src="https://yqypicbed.oss-cn-hangzhou.aliyuncs.com/typoraoss/image-20220222141236206.png" alt="image-20220222141236206" width="500" />

<p>接下来继续在python3环境中测试下pytorch的功能</p>
<p><strong>from</strong> <strong>future</strong> <strong>import</strong> print_function</p>
<p><strong>import</strong> torch</p>
<p>x <strong>&#x3D;</strong> torch**.**rand(5, 3)</p>
<p><strong>print</strong>(x)</p>
<p>输出</p>
<p>tensor([[0.3380, 0.3845, 0.3217],</p>
<p>​    [0.8337, 0.9050, 0.2650],</p>
<p>​    [0.2979, 0.7141, 0.9069],</p>
<p>​    [0.1449, 0.1132, 0.1375],</p>
<p>​    [0.4675, 0.3947, 0.1426]])</p>
<p>另外，要检查你的GPU驱动程序和CUDA是否启用，并通过PyTorch访问，运行以下命令返回是否启用CUDA驱动程序</p>
<p><strong>import</strong> torch</p>
<p>torch.cuda.is_available()</p>
<p>测试完毕后接下来再安装torchvision,根官网介绍,pytorch1.6吻合的torch版本为0.7.0</p>
<img src="https://yqypicbed.oss-cn-hangzhou.aliyuncs.com/typoraoss/image-20220222141251282.png" alt="image-20220222141251282" width="500" style="zoom:50%;" />



<p>sudo apt-get install libjpeg-dev zlib1g-dev</p>
<p>git clone –branch v0.7.0 <a target="_blank" rel="noopener" href="https://github.com/pytorch/vision">https://github.com/pytorch/vision</a> torchvision</p>
<p>cd torchvision</p>
<p>export BUILD_VERSION&#x3D;0.7.0</p>
<p>sudo python3 setup.py install</p>
<p>注意:安装可能会确实一些文件，这个可以安装相应的文件来解决，例如笔者遇到的是确实一下三个文件所以按了一下三个包</p>
<img src="https://yqypicbed.oss-cn-hangzhou.aliyuncs.com/typoraoss/image-20220222141306843.png" alt="image-20220222141306843" width="1000" style="zoom:50%;" />

<p>sudo apt install libavcodec-dev</p>
<p>sudo apt install libavformat-dev</p>
<p>sudo apt install libswscale-dev</p>
<p>重新sudo python3 setup.py install</p>
<p>到python环境中输入下代码可以查看版本是否对应</p>
<p>import torchvision</p>
<p>print(torchvision.<strong>version</strong>)</p>
<img src="https://yqypicbed.oss-cn-hangzhou.aliyuncs.com/typoraoss/image-20220222141316874.png" alt="image-20220222141316874" width="500" style="zoom:50%;" />



<h1 id="jetson-nao其他配置"><a href="#jetson-nao其他配置" class="headerlink" title="jetson nao其他配置"></a>jetson nao其他配置</h1><h2 id="1-更新镜像源"><a href="#1-更新镜像源" class="headerlink" title="1. 更新镜像源"></a>1. 更新镜像源</h2><h3 id="1-1-apt"><a href="#1-1-apt" class="headerlink" title="1.1. apt"></a>1.1. apt</h3><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">sudo <span class="built_in">cp</span> /etc/apt/sources.list /etc/apt/sources.list.bak</span><br></pre></td></tr></table></figure>

<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">sudo vim /etc/apt/sources.list.bak</span><br></pre></td></tr></table></figure>

<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">ggVG  全选</span><br><span class="line">dG		删除</span><br></pre></td></tr></table></figure>

<ul>
<li><strong>源：</strong></li>
</ul>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line">deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ bionic main multiverse restricted universe</span><br><span class="line">deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ bionic-security main multiverse restricted universe</span><br><span class="line">deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ bionic-updates main multiverse restricted universe</span><br><span class="line">deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ bionic-backports main multiverse restricted universe</span><br><span class="line">deb-src http://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ bionic main multiverse restricted universe</span><br><span class="line">deb-src http://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ bionic-security main multiverse restricted universe</span><br><span class="line">deb-src http://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ bionic-updates main multiverse restricted universe</span><br><span class="line">deb-src http://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ bionic-backports main multiverse restricted universe</span><br></pre></td></tr></table></figure>

<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">sudo apt-get update 		//更新</span><br></pre></td></tr></table></figure>



<h3 id="1-2-pip"><a href="#1-2-pip" class="headerlink" title="1.2. pip"></a>1.2. pip</h3><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">sudo apt-get install python3-pip python3-dev</span><br></pre></td></tr></table></figure>

 <figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">sudo apt-get install python-pip python-dev</span><br></pre></td></tr></table></figure>



<ul>
<li><strong>pip换源</strong></li>
</ul>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line">$ sudo <span class="built_in">mkdir</span> .pip		<span class="comment">#创建隐藏文件夹</span></span><br><span class="line">$ <span class="built_in">ls</span> -a  						<span class="comment">#查看所有文件</span></span><br><span class="line">$ <span class="built_in">cd</span> .pip						<span class="comment">#进入文件夹</span></span><br><span class="line">$ sudo <span class="built_in">touch</span> pip.conf</span><br><span class="line">$ sudo vim pip.conf</span><br></pre></td></tr></table></figure>

<ul>
<li><strong>源</strong>:</li>
</ul>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">[global]</span><br><span class="line">timeout = 6000</span><br><span class="line">index-url = http://pypi.doubanio.com/simple/</span><br><span class="line">trusted-host = pypi.doubanio.com</span><br></pre></td></tr></table></figure>



<h3 id="1-3-docker"><a href="#1-3-docker" class="headerlink" title="1.3. docker"></a>1.3. docker</h3><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line"><span class="built_in">cat</span> /etc/issue  <span class="comment">#查看ubantu版本</span></span><br></pre></td></tr></table></figure>

<p>查看Ubuntu系统版本号</p>
<p>根据Ubuntu的版本号，配置相关的源镜像。跳转到源文件所在的目录</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line"><span class="built_in">cd</span>  /etc/apt/</span><br></pre></td></tr></table></figure>

<p>可以试用文件编辑工具打开sources.list文件</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">sudo gedit /etc/apt/sources.list</span><br></pre></td></tr></table></figure>

<p>直接用以下内容替换 sources.list文件中的所有内容即可。</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">deb https://mirrors.ustc.edu.cn/ubuntu-ports/ bionic main restricted universe multiverse</span><br><span class="line">deb https://mirrors.ustc.edu.cn/ubuntu-ports/ bionic-updates main restricted universe multiverse</span><br><span class="line">deb https://mirrors.ustc.edu.cn/ubuntu-ports/ bionic-backports main restricted universe multiverse</span><br><span class="line">deb https://mirrors.ustc.edu.cn/ubuntu-ports/ bionic-security main restricted universe multiverse</span><br></pre></td></tr></table></figure>

<p>更新了源文件之后，保存退出</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">sudo apt-get update</span><br></pre></td></tr></table></figure>





<h2 id="2-安装pytorch和torchvison"><a href="#2-安装pytorch和torchvison" class="headerlink" title="2. 安装pytorch和torchvison"></a>2. 安装pytorch和torchvison</h2><ul>
<li><p><a target="_blank" rel="noopener" href="https://forums.developer.nvidia.com/t/pytorch-for-jetson-version-1-10-now-available/72048">官网教程</a></p>
</li>
<li><p>版本要对应</p>
</li>
</ul>
<img src="https://img2020.cnblogs.com/blog/1733978/202104/1733978-20210414172645876-1962676.png" alt="img" style="zoom: 67%;" width="1000"/>

<ul>
<li><p>下载官方提供的<a target="_blank" rel="noopener" href="https://nvidia.box.com/shared/static/p57jwntv436lfrd78inwl7iml6p13fzh.whl">torch-1.8.0-cp36-cp36m-linux_aarch64.whl</a>包</p>
</li>
<li><p>按照官方教程输入以下命令</p>
</li>
</ul>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line">$ sudo apt-get install python3-pip libopenblas-base libopenmpi-dev</span><br><span class="line">$ pip3 install Cython</span><br><span class="line">$ pip3 install numpy torch-1.8.0-cp36-cp36m-linux_aarch64.whl <span class="comment"># (按照自己torch1.8.0包的下载路径修改，此过程较慢）</span></span><br><span class="line">$ sudo apt-get install libjpeg-dev zlib1g-dev libpython3-dev libavcodec-dev libavformat-dev libswscale-dev</span><br><span class="line">$ git <span class="built_in">clone</span> --branch v0.9.0 https://github.com/pytorch/vision torchvision</span><br><span class="line">$ <span class="built_in">cd</span> torchvision</span><br><span class="line">$ <span class="built_in">export</span> BUILD_VERSION=0.9.0</span><br><span class="line">$ python3 setup.py install --user <span class="comment">#时间较长</span></span><br></pre></td></tr></table></figure>

<ul>
<li>检查环境</li>
</ul>
<figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line">python3</span><br><span class="line"><span class="keyword">import</span> torch</span><br><span class="line"><span class="keyword">import</span> torchvision</span><br><span class="line"><span class="built_in">print</span>(torch.__version__)</span><br><span class="line"><span class="built_in">print</span>(torchvision.__version__)</span><br><span class="line">torch.cuda.is_available()</span><br></pre></td></tr></table></figure>



<img src="https://yqypicbed.oss-cn-hangzhou.aliyuncs.com/typoraoss/image-20220226195653355.png" alt="image-20220226195653355" style="zoom:50%;" />





<h2 id="3-miniforge包管理-选"><a href="#3-miniforge包管理-选" class="headerlink" title="3. miniforge包管理(选)"></a>3. miniforge包管理(选)</h2><p>:bangbang:<strong><font color='red'>此内容为可非必要配置，因为jetson是arm版本无法直接安装anaconda环境，如果需要在jetson上安装anaconda可以接着往下看，若不需要，请跳过</font></strong></p>
<h3 id="3-1-miniforge简介"><a href="#3-1-miniforge简介" class="headerlink" title="3.1. miniforge简介"></a>3.1. <a target="_blank" rel="noopener" href="https://github.com/conda-forge/miniforge/releases">miniforge简介</a></h3><p>conda是一个开源的包、环境管理器，可以用于在同一个机器上安装不同版本的软件包及其依赖，并能够在不同的环境之间切换。搞深度学习的应该都十分熟悉anaconda，但是NVIDIA Jetson Xavier NX是<strong>arm</strong>架构的，anaconda及其精简版miniconda并不支持arm64架构。现在主流的CPU架构分为Intel的x86&#x2F;x64架构和ARM的ARM&#x2F;ARM64两种，平常用的电脑大部分都是x86&#x2F;x64的（苹果除外），Xavier使用的是ARM64，所以很多在x86&#x2F;x64上能用的的东西到了它这里就不能用了。<strong>这一点请谨记，如果你在Jetson上遇到什么奇奇怪怪的例如“No such file or directory”之类的问题，第一时间要考虑是不是版本不是ARM64的版本</strong>。<br>在ARM64上的anaconda替代品是miniforge，miniforge与miniconda的区别在于miniforge的下载通道是conda-forge，其他基本没什么不同。</p>
<h3 id="3-2-安装miniforge"><a href="#3-2-安装miniforge" class="headerlink" title="3.2. 安装miniforge"></a>3.2. 安装miniforge</h3><ol>
<li><p>我下载的是 <code>Miniforge-pypy3-4.11.0-0-Linux-aarch64.sh</code>,,代表适用于arrch64架构下的Linux系统。（ARM64对应32位和64位分为arrch32和arrch64）</p>
</li>
<li><p>进入到miniforge的sh文件所在目录，右键打开Terminal，输入以下命令进行安装：</p>
</li>
</ol>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">sh Miniforge-pypy3-4.10.3-3-Linux-aarch64.sh</span><br></pre></td></tr></table></figure>

<ol start="3">
<li>安装完毕后，添加环境变量，否则会出现<code>bash:conda Command not found</code>的错误。顺便提一下vim编辑器按a是进入编辑模式，编辑完毕后按ESC退出编辑模式，再输入:wq!是保存并退出。</li>
</ol>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment"># 编辑环境变量</span></span><br><span class="line">vim ~/.bashrc</span><br><span class="line"><span class="comment"># 增加环境变量, 将&lt;username&gt;换成你的用户名</span></span><br><span class="line"><span class="built_in">export</span> PATH=/home/&lt;username&gt;/miniforge-pypy3/bin:<span class="variable">$PATH</span></span><br><span class="line"><span class="comment"># 激活环境变量</span></span><br><span class="line"><span class="built_in">source</span> ~/.bashrc</span><br><span class="line"><span class="comment"># 显示(base)</span></span><br><span class="line"><span class="built_in">source</span> activate</span><br></pre></td></tr></table></figure>

<ol start="4">
<li>更换清华源</li>
</ol>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">conda config --prepend channels https://mirrors.ustc.edu.cn/anaconda/pkgs/main/</span><br><span class="line">conda config --prepend channels https://mirrors.ustc.edu.cn/anaconda/pkgs/free/</span><br><span class="line">conda config --<span class="built_in">set</span> show_channel_urls <span class="built_in">yes</span></span><br></pre></td></tr></table></figure>





<h3 id="3-3-安装pytorch、torchvision"><a href="#3-3-安装pytorch、torchvision" class="headerlink" title="3.3. 安装pytorch、torchvision"></a>3.3. 安装pytorch、torchvision</h3><h3 id="3-4-安装新的虚拟环境"><a href="#3-4-安装新的虚拟环境" class="headerlink" title="3.4. 安装新的虚拟环境"></a>3.4. 安装新的虚拟环境</h3><ul>
<li>这是在minigorge上安装的pytorch，若不想在虚拟环境上安装。可以参考<a target="_blank" rel="noopener" href="https://forums.developer.nvidia.com/t/pytorch-for-jetson-version-1-10-now-available/72048">PyTorch for Jetson - version 1.10 now available - Jetson &amp; Embedded Systems &#x2F; Jetson Nano - NVIDIA Developer Forums</a></li>
</ul>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">conda create -n pytorch python=3.6	<span class="comment">#创建环境</span></span><br><span class="line">conda activate pytorch							<span class="comment">#激活环境</span></span><br><span class="line"></span><br></pre></td></tr></table></figure>



<ul>
<li>其他操作（看即可）</li>
</ul>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">conda deactivate										<span class="comment">#退出环境</span></span><br><span class="line">conda remove -n pytorch --all</span><br><span class="line"></span><br><span class="line">conda info -e												<span class="comment">#查看已有环境</span></span><br></pre></td></tr></table></figure>





<p>激活成功会换名字</p>
<img src="https://yqypicbed.oss-cn-hangzhou.aliyuncs.com/typoraoss/image-20220222141336662.png" alt="image-20220222141336662" width="1000" style="zoom:50%;" />



<h3 id="3-5-pytorch1-8"><a href="#3-5-pytorch1-8" class="headerlink" title="3.5. pytorch1.8"></a>3.5. pytorch1.8</h3><p>直接输入命令安装PyTorch，<code>pip3</code>是python3的pip，如果没装，就换成<code>pip</code>。</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">pip3 install -U future psutil dataclasses typing-extensions pyyaml tqdm seaborn</span><br><span class="line">wget https://nvidia.box.com/shared/static/p57jwntv436lfrd78inwl7iml6p13fzh.whl -O torch-1.8.0-cp36-cp36m-linux_aarch64.whl</span><br><span class="line">pip3 install torch-1.8.0-cp36-cp36m-linux_aarch64.whl</span><br></pre></td></tr></table></figure>

<p>如果网络不好的话，也可以先把PyTorch的whl文件下载下来，NVIDIA官方网址是：<a target="_blank" rel="noopener" href="https://forums.developer.nvidia.com/t/pytorch-for-jetson-version-1-9-0-now-available/72048">https://forums.developer.nvidia.com/t/pytorch-for-jetson-version-1-9-0-now-available/72048</a></p>
<ul>
<li><strong>&#x3D;&#x3D;<font color='red'>issue:</font>&#x3D;&#x3D;</strong></li>
</ul>
<p>如果出现<code>Illegal instruction (core dumped)</code>的错误，这是由于numpy 1.19.5和OpenBLAS冲突引起的，修改其中一项即可。选择以下两种做法之一：<br>（1）降低numpy版本</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">pip3 install -U <span class="string">&quot;numpy==1.19.4&quot;</span></span><br></pre></td></tr></table></figure>

<p>(2)设置OpenBLAS</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">vim ~/.bashrc</span><br></pre></td></tr></table></figure>

<p>加入</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line"><span class="built_in">export</span> OPENBLAS_CORETYPE=ARMV8</span><br></pre></td></tr></table></figure>

<p>然后激活.bashrc</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line"><span class="built_in">source</span> ~/.bashrc</span><br></pre></td></tr></table></figure>



<h3 id="3-6-orchvision-v0-9-0"><a href="#3-6-orchvision-v0-9-0" class="headerlink" title="3.6. orchvision v0.9.0"></a>3.6. orchvision v0.9.0</h3><h2 id="4-查看jetson信息-（jtop）"><a href="#4-查看jetson信息-（jtop）" class="headerlink" title="4. 查看jetson信息 （jtop）"></a>4. 查看jetson信息 （jtop）</h2><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">sudo pip3 install jetson-stats</span><br><span class="line">sudo jtop</span><br></pre></td></tr></table></figure>





<h2 id="5-风扇自动控制"><a href="#5-风扇自动控制" class="headerlink" title="5. 风扇自动控制"></a>5. <a target="_blank" rel="noopener" href="https://github.com/Pyrestone/jetson-fan-ctl.git">风扇自动控制</a></h2><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">git <span class="built_in">clone</span> https://gitee.com/yin-qiyu/jetson-fan-ctl.git</span><br></pre></td></tr></table></figure>

<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line"><span class="built_in">cd</span> /jetson-fan-ctl <span class="comment">#进入文件夹</span></span><br></pre></td></tr></table></figure>

<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">sudo apt install python3-dev</span><br></pre></td></tr></table></figure>

<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">sudo ./install.sh</span><br></pre></td></tr></table></figure>

<p>现在你的风扇就可以按照温度自动调整运行速度了<br>风扇的一些设置在<code>/etc/automagic-fan/config.json</code>目录下。</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">vim /etc/automagic-fan/config.json</span><br></pre></td></tr></table></figure>

<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line">&#123;undefined</span><br><span class="line">“FAN_OFF_TEMP”:20,</span><br><span class="line">“FAN_MAX_TEMP”:50,</span><br><span class="line">“UPDATE_INTERVAL”:2,</span><br><span class="line">“MAX_PERF”:1</span><br><span class="line">&#125;</span><br><span class="line">~</span><br><span class="line">~</span><br></pre></td></tr></table></figure>



<h2 id="6-增加Swap分区大小"><a href="#6-增加Swap分区大小" class="headerlink" title="6. 增加Swap分区大小"></a>6. 增加Swap分区大小</h2><ul>
<li>先查看初试交换分区大小：</li>
</ul>
<img src="https://yqypicbed.oss-cn-hangzhou.aliyuncs.com/typoraoss/image-20220222141405289.png" alt="image-20220222141405289" width="800" />

<ul>
<li>生成swapfile文件操作如下</li>
</ul>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">#1）新增swapfile文件大小自定义</span></span><br><span class="line">sudo fallocate -l 6G /var/swapfile</span><br><span class="line"><span class="comment">#2）配置该文件的权限</span></span><br><span class="line">sudo <span class="built_in">chmod</span> 600 /var/swapfile</span><br><span class="line"><span class="comment">#3）建立交换分区</span></span><br><span class="line">sudo mkswap /var/swapfile</span><br><span class="line"><span class="comment">#4）启用交换分区</span></span><br><span class="line">sudo swapon /var/swapfile</span><br></pre></td></tr></table></figure>

<ul>
<li>设置为自动启用swapfile</li>
</ul>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">sudo bash -c <span class="string">&#x27;echo &quot;/var/swapfile swap swap defaults 0 0&quot; &gt;&gt; /etc/fstab&#x27;</span></span><br></pre></td></tr></table></figure>

<p>设置成功后：</p>
<img src="https://yqypicbed.oss-cn-hangzhou.aliyuncs.com/typoraoss/image-20220222141420401.png" alt="image-20220222141420401" width="1000" />





<h2 id="7-nomachine（虚拟网络控制台）"><a href="#7-nomachine（虚拟网络控制台）" class="headerlink" title="7. nomachine（虚拟网络控制台）"></a>7. nomachine（虚拟网络控制台）</h2><p>官网：<a target="_blank" rel="noopener" href="https://www.nomachine.com/">NoMachine - Free Remote Desktop For Everybody</a></p>
<ul>
<li><p>主机上正常安装</p>
</li>
<li><p>jetson上</p>
<ul>
<li><p>下载好对应版本用SFTP传到jetson</p>
</li>
<li><pre><code class="bash">sudo dpkg -i nomachine_7.6.2_3_arm64.deb
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br></pre></td><td class="code"><pre><span class="line"></span><br><span class="line">- 在同一局域网下即可连接</span><br><span class="line"></span><br><span class="line">&lt;img src=&quot;https://yqypicbed.oss-cn-hangzhou.aliyuncs.com/typoraoss/image-20220403144934094.png&quot; alt=&quot;image-20220403144934094&quot; width=&quot;500&quot; /&gt;</span><br><span class="line"></span><br><span class="line">&lt;img src=&quot;https://yqypicbed.oss-cn-hangzhou.aliyuncs.com/typoraoss/image-20220403145033336.png&quot; alt=&quot;image-20220403145033336&quot; width=&quot;500&quot; /&gt;</span><br><span class="line"></span><br><span class="line"></span><br><span class="line"></span><br><span class="line"></span><br><span class="line"></span><br><span class="line">## 8. VNC（虚拟网络控制台）</span><br><span class="line"></span><br><span class="line">- 编辑文件</span><br><span class="line"></span><br><span class="line">```bash</span><br><span class="line">sudo vim /usr/share/glib-2.0/schemas/org.gnome.Vino.gschema.xml</span><br></pre></td></tr></table></figure>
</code></pre>
</li>
</ul>
</li>
<li><p>滑到文末添加下段内容格式如图片所示</p>
</li>
</ul>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br></pre></td><td class="code"><pre><span class="line">&lt;key name=<span class="string">&quot;enabled&quot;</span> <span class="built_in">type</span>=<span class="string">&quot;b&quot;</span>&gt;</span><br><span class="line">   &lt;summary&gt;Enable remote access to the desktop&lt;/summary&gt;</span><br><span class="line">   &lt;description&gt;</span><br><span class="line">    If <span class="literal">true</span>, allows remote access to the desktop via the RFB</span><br><span class="line">    protocol. Users on remote machines may <span class="keyword">then</span> connect to the</span><br><span class="line">    desktop using a VNC viewer.</span><br><span class="line">   &lt;/description&gt;</span><br><span class="line">   &lt;default&gt;<span class="literal">false</span>&lt;/default&gt;</span><br><span class="line">  &lt;/key&gt;</span><br></pre></td></tr></table></figure>

<img src="https://yqypicbed.oss-cn-hangzhou.aliyuncs.com/typoraoss/image-20220226204438666.png" alt="image-20220226204438666" style="zoom:50%;" />

<ul>
<li>编译文件</li>
</ul>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">sudo glib-compile-schemas /usr/share/glib-2.0/schemas</span><br></pre></td></tr></table></figure>

<p>完成以上步骤，正常来说就可以打开桌面共享的图标了。</p>
<img src="https://yqypicbed.oss-cn-hangzhou.aliyuncs.com/typoraoss/image-20220222141452790.png" alt="image-20220222141452790" width="500" />

<p>设置好后（不设置也可以）</p>
<img src="https://img-blog.csdnimg.cn/20200602124909227.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3dlaXhpbl80MzE4MTM1MA==,size_16,color_FFFFFF,t_70" alt="在这里插入图片描述"  />

<ul>
<li>配置vnc设置</li>
</ul>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">$ gsettings <span class="built_in">set</span> org.gnome.Vino prompt-enabled <span class="literal">false</span></span><br><span class="line">$ gsettings <span class="built_in">set</span> org.gnome.Vino require-encryption <span class="literal">false</span></span><br></pre></td></tr></table></figure>

<ul>
<li>设置密码（可以不要）</li>
</ul>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">$ gsettings <span class="built_in">set</span> org.gnome.Vino authentication-methods <span class="string">&quot;[&quot;</span>vnc<span class="string">&quot;]&quot;</span></span><br><span class="line">$ gsettings <span class="built_in">set</span> org.gnome.Vino vnc-password $(<span class="built_in">echo</span> -n <span class="string">&quot;请输入你的密码&quot;</span>|<span class="built_in">base64</span>)</span><br></pre></td></tr></table></figure>



<ul>
<li>配置vnc自启</li>
</ul>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">$ gsettings <span class="built_in">set</span> org.gnome.Vino enabled <span class="literal">true</span></span><br><span class="line">$ <span class="built_in">mkdir</span> -p ~/.config/autostart</span><br><span class="line">$ vi  ~/.config/autostart/vino-server.desktop</span><br></pre></td></tr></table></figure>

<p>添加下面内容</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br></pre></td><td class="code"><pre><span class="line">[Desktop Entry]</span><br><span class="line"></span><br><span class="line">Type=Application</span><br><span class="line"></span><br><span class="line">Name=Vino VNC server</span><br><span class="line"></span><br><span class="line">Exec=/usr/lib/vino/vino-server</span><br><span class="line"></span><br><span class="line">NoDisplay=<span class="literal">true</span></span><br></pre></td></tr></table></figure>

<ul>
<li><font color='red'>重启生效</font></li>
</ul>
 <figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">$ sudo reboot</span><br></pre></td></tr></table></figure>



<ul>
<li><p>电脑端可下载<a target="_blank" rel="noopener" href="https://www.realvnc.com/en/connect/download/viewer/">Download VNC Viewer | VNC® Connect (realvnc.com)</a></p>
</li>
<li><img src="https://yqypicbed.oss-cn-hangzhou.aliyuncs.com/typoraoss/image-20220226204943881.png" alt="image-20220226204943881" style="zoom:33%;" />
</li>
<li><p>配置jetson nano的ip和密码即可连接</p>
</li>
<li><ul>
<li><p>遇到下图提示输入电脑账户魔密码即可（是你主机的密码，不是jetson的）</p>
<img src="https://yqypicbed.oss-cn-hangzhou.aliyuncs.com/typoraoss/image-20220302182808960.png" alt="image-20220302182808960" style="zoom:50%;" />

<img src="https://yqypicbed.oss-cn-hangzhou.aliyuncs.com/typoraoss/image-20220312224805927.png" alt="image-20220312224805927" width="500" /></li>
</ul>
</li>
</ul>
<h2 id="9-TensoRT"><a href="#9-TensoRT" class="headerlink" title="9. TensoRT"></a>9. TensoRT</h2><h3 id="9-1-TensoRT介绍："><a href="#9-1-TensoRT介绍：" class="headerlink" title="9.1. TensoRT介绍："></a>9.1. TensoRT介绍：</h3><p>​	模型加速越来越成为深度学习工程中的刚需了，最近的CVPR和ICLR会议中，模型的压缩和剪枝是受到的关注越来越多。毕竟工程上，算法工程师的深度学习模型是要在嵌入式平台跑起来，投入应用的。在模型的推理（inference）过程中，计算速度是很重要的。比如自动驾驶，如果使用一个经典的深度学习模型，很容易就跑到200毫秒的延时，那么这意味着，在实际驾驶过程中，你的车一秒钟只能看到5张图像，这当然是很危险的一件事。所以，对于实时响应比较高的任务，模型的加速时很有必要的一件事情了。</p>
<p>如果你使用英伟达的产品，比如PX2，那么在平台上部署模型投入应用，很多时候就需要用到专门的模型加速工具 —— TensorRT。</p>
<p><strong>TensorRT下的模型是在做什么？</strong></p>
<p>TensorRT只负责模型的推理（inference）过程，一般不用TensorRT来训练模型的哈。</p>
<p><strong>TensorRT能加速模型吗？</strong></p>
<p>能！根据官方文档，使用TensorRT，在CPU或者GPU模式下其可提供10X乃至100X的加速。本人的实际经验中，TensorRT提供了20X的加速。</p>
<p><strong>TensorRT为什么能提升模型的运行速度？</strong></p>
<p>TensorRT是英伟达针对自家平台做的加速包，TensorRT主要做了这么两件事情，来提升模型的运行速度。</p>
<ol>
<li>TensorRT支持INT8和FP16的计算。深度学习网络在训练时，通常使用 32 位或 16 位数据。TensorRT则在网络的推理时选用不这么高的精度，达到加速推断的目的。</li>
<li>TensorRT对于网络结构进行了重构，把一些能够合并的运算合并在了一起，针对GPU的特性做了优化。现在大多数深度学习框架是没有针对GPU做过性能优化的，而英伟达，GPU的生产者和搬运工，自然就推出了针对自己GPU的加速工具TensorRT。一个深度学习模型，在没有优化的情况下，比如一个卷积层、一个偏置层和一个reload层，这三层是需要调用三次cuDNN对应的API，但实际上这三层的实现完全是可以合并到一起的，TensorRT会对一些可以合并网络进行合并。</li>
</ol>
<img src="https://developer.nvidia.com/sites/default/files/akamai/deeplearning/tensorrt/trt-info.png" alt="img" style="zoom:50%;" />

<h3 id="9-2-检查自带TensorRT环境（选）"><a href="#9-2-检查自带TensorRT环境（选）" class="headerlink" title="9.2. 检查自带TensorRT环境（选）"></a>9.2. 检查自带TensorRT环境（选）</h3><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line"><span class="built_in">cd</span> /usr/src/tensorrt/samples</span><br><span class="line">sudo make		<span class="comment">#编译大约7分钟</span></span><br><span class="line">../bin/sample_mnist</span><br></pre></td></tr></table></figure>

<img src="https://yqypicbed.oss-cn-hangzhou.aliyuncs.com/typoraoss/image-20220222141611316.png" alt="image-20220222141611316" width="300" />



<img src="https://yqypicbed.oss-cn-hangzhou.aliyuncs.com/typoraoss/image-20220312212555390.png" alt="image-20220312212555390" width="400" />

<h3 id="9-3-jetson-inference库安装（选）"><a href="#9-3-jetson-inference库安装（选）" class="headerlink" title="9.3. jetson inference库安装（选）"></a>9.3. <a target="_blank" rel="noopener" href="https://github.com/dusty-nv/jetson-inference">jetson inference</a>库安装（选）</h3><p><a target="_blank" rel="noopener" href="https://www.bilibili.com/read/cv13998685"> 参考资料 </a></p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br></pre></td><td class="code"><pre><span class="line">sudo apt update</span><br><span class="line">sudo apt autoremove</span><br><span class="line">sudo apt upgrade</span><br><span class="line">sudo apt install cmake</span><br><span class="line"><span class="built_in">mkdir</span> ~/workspace</span><br><span class="line"><span class="built_in">cd</span> workspace</span><br><span class="line">git <span class="built_in">clone</span> https://gitee.com/weikun-xuan/jetson-inference.git</span><br><span class="line"><span class="built_in">cd</span> jetson-inference</span><br><span class="line">git submodule update --init</span><br></pre></td></tr></table></figure>

<blockquote>
<p>start</p>
</blockquote>
<p>一、获取源码<br>首先打开终端运行如下代码：</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line">sudo apt-get update</span><br><span class="line"></span><br><span class="line">sudo apt-get install git cmake libpython3-dev python3-numpy</span><br><span class="line"></span><br><span class="line">git <span class="built_in">clone</span> --recursive https://gitee.com/weikun-xuan/jetson-inference.git</span><br></pre></td></tr></table></figure>


<p>上面仓库源我全都自己换了，下载会比GitHub快很多。</p>
<p>二、换源<br>进入到tools文件下：</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line"><span class="built_in">cd</span> jetson-inference/tools</span><br><span class="line"></span><br></pre></td></tr></table></figure>


<p>换下源，依次运行以下代码（均在tools文件下）：</p>
<p>1）模型下载国内源：</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">$ sed -in-place -e <span class="string">&#x27;s@https://nvidia.box.com/shared/static@https://bbs.gpuworld.cn/mirror@g&#x27;</span> download-models.sh</span><br></pre></td></tr></table></figure>

<p>2）pytorch国内源：</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line">$ sed -in-place -e <span class="string">&#x27;s@https://nvidia.box.com/shared/static@https://bbs.gpuworld.cn/mirror@g&#x27;</span> install-pytorch.sh</span><br><span class="line"></span><br><span class="line">$ sed -in-place -e <span class="string">&#x27;s@https://github.com/pytorch/vision@https://gitee.com/vcan123/pytorch@g&#x27;</span> install-pytorch.sh</span><br><span class="line"></span><br><span class="line">$ sed -in-place -e <span class="string">&#x27;s@https://github.com/dusty-nv/vision@https://gitee.com/vcan123/dusty-nv@g&#x27;</span> install-pytorch.sh</span><br></pre></td></tr></table></figure>


<p>三、编译安装</p>
<p>在jetson-infernce文件下执行如下操作：</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line"><span class="built_in">mkdir</span> build</span><br><span class="line"></span><br><span class="line"><span class="built_in">cd</span> build</span><br><span class="line"></span><br><span class="line">cmake ../</span><br></pre></td></tr></table></figure>


<p> 接着就会出现：</p>
<p>模型包安装</p>
<p> 此步为安装模型包，本人建议【全部取消】，不然会有些慢，之后我们可以去<a target="_blank" rel="noopener" href="https://github.com/dusty-nv/jetson-inference/releases">官网</a>手动下载。</p>
<p>我们继续：</p>
<p>pytorch安装</p>
<p> 安装pytorch。这时应该只有一个for python 3.6版本,选上然后ok。</p>
<p>完成后还是在build文件下依次执行如下操作：</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line">$ make</span><br><span class="line"></span><br><span class="line">$ sudo make install</span><br><span class="line"></span><br><span class="line">$ sudo ldconfig</span><br></pre></td></tr></table></figure>


<p>完成。</p>
<h2 id="10-安装jupyter和jetcam"><a href="#10-安装jupyter和jetcam" class="headerlink" title="10. 安装jupyter和jetcam"></a>10. 安装jupyter和jetcam</h2><ol>
<li><strong>安装nodejs和npm</strong></li>
</ol>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">pip3 install --upgrade pip	<span class="comment">#更新pip</span></span><br><span class="line">sudo apt install nodejs npm</span><br></pre></td></tr></table></figure>

<p>但是用直接用上面这个命令安装后的版本是比较低的后续要安装jupyterlab插件可能会报错，用一下版本可以查看,至少要12.3.0版本的node</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">node -v</span><br><span class="line">npm -v</span><br></pre></td></tr></table></figure>



<p>安装n模块，用这个模块来更新或者指定安装node的版本</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">sudo npm install -g n</span><br></pre></td></tr></table></figure>

<p>先说明下这个模块的功能，一下命令了解下先，不用操作</p>
<p>清除npm缓存：npm cache clean -f</p>
<p>安装n模块：npm install -g n</p>
<p>安装官方稳定版本：n stable</p>
<p>安装最新官方版本：n latest</p>
<p>安装某个指定版本：n 11.6.0</p>
<p>查看已安装的node版本: n</p>
<p>查看当前node版本：node -v</p>
<p>删除指定版本：n rm 7.5.0</p>
<p>好的，了解完n模块的功能后来安装对应版本的node,也可以安装最新版的例如以下，</p>
<p>sudo n latest</p>
<p>安装好后，node -v 查看下版本，如果版本没有变，那么可以尝试重启下，如果还是没有变，执行</p>
<p>sudo n</p>
<p>会出现一个画面，可以看到我们安装过的node版本名，例如我们这里是v15.0.1，通过上下方向按键控制光标选择这个版本，然后回车镜像安装，然后查看下版本，如果还是没有变，一般再重启下就可以了。</p>
<ol start="2">
<li><strong>安装jupyterlab</strong>：（警告忽略，失败多次执行即可）</li>
</ol>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line">sudo pip3 install jupyter jupyterlab</span><br><span class="line"></span><br><span class="line">sudo jupyter labextension install @jupyter-widgets/jupyterlab-manager</span><br><span class="line"></span><br><span class="line">sudo jupyter labextension install @jupyterlab/statusbar</span><br></pre></td></tr></table></figure>

<p>生成相应配置文件：（如果某个文件报权限问题，可以尝试用sudo chmod 777赋予权限）</p>
<p>jupyter lab –generate-config</p>
<p>设置进入notebook的密码（这里会要设置两次，第二次为确认输入的密码）：</p>
<p>jupyter notebook password</p>
<p>当第一次登录使用notebook时需要输入你在这里设置的密码才能进入，请务必记住的当前设置的密码！</p>
<p>设置开机自启动jupterlab，create_jupyter_service.py文件</p>
<p>运行create_jupyter_service.py文件产生jupyter_service.service文件</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">python3 create_jupyter_service.py</span><br></pre></td></tr></table></figure>

<p>然后将产生的该服务文件移动至系统服务</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">sudo <span class="built_in">mv</span> nano_jupyter.service /etc/systemd/system/nano_jupyter.service</span><br></pre></td></tr></table></figure>

<p>使能该服务</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">sudo systemctl <span class="built_in">enable</span> nano_jupyter.service</span><br></pre></td></tr></table></figure>

<p>手动开启该服务</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">sudo systemctl start nano_jupyter.service</span><br></pre></td></tr></table></figure>



<ol start="3">
<li><strong>安装jetcam</strong></li>
</ol>
<p>JetCam是用于NVIDIA Jetson的易于使用的Python相机界面。使用Jetson的<a target="_blank" rel="noopener" href="https://developer.download.nvidia.com/embedded/L4T/r32_Release_v1.0/Docs/Accelerated_GStreamer_User_Guide.pdf?uIzwdFeQNE8N-vV776ZCUUEbiJxYagieFEqUoYFM9XSf9tbslxWqFKnVHu8erbZZS20A7ADAIgmSQJvXZTb0LkuGl9GoD5HJz4263HcmYWZW0t2OeFSJKZOfuWZ-lF51Pva2DSDtu2QPs-junm7BhMB_9AMQRwExuDb5zIhf_o8PIbA4KKo">Accelerated GStreamer插件可</a>与各种USB和CSI摄像机配合使用。轻松读取图像作为numpy数组image &#x3D; camera.read()。设置相机以running &#x3D; True将回调附加到新框架。JetCam使在Python中创建AI项目的原型变得容易，尤其是在<a target="_blank" rel="noopener" href="http://github.com/NVIDIA-AI-IOT/jetcard">JetCard中</a>安装的Jupyter Lab编程环境中。</p>
<p>接下来开始安装:</p>
<p>git clone <a target="_blank" rel="noopener" href="https://github.com/NVIDIA-AI-IOT/jetcam">https://github.com/NVIDIA-AI-IOT/jetcam</a></p>
<p>cd jetcam</p>
<p>sudo python3 setup.py install</p>
<p>详细的使用即函数可以到<a target="_blank" rel="noopener" href="https://github.com/NVIDIA-AI-IOT/jetcam%E6%9F%A5%E7%9C%8B">https://github.com/NVIDIA-AI-IOT/jetcam查看</a></p>
<h2 id="11-darknet框架（选）"><a href="#11-darknet框架（选）" class="headerlink" title="11. darknet框架（选）"></a>11. darknet框架（选）</h2><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">git <span class="built_in">clone</span> https://github.com/AlexeyAB/darknet.git <span class="comment">#下载darknet框架</span></span><br></pre></td></tr></table></figure>

<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">$ <span class="built_in">cd</span> darknet</span><br><span class="line"></span><br><span class="line">$ sudo vim Makefile   <span class="comment">#修改Makefile</span></span><br></pre></td></tr></table></figure>

<ul>
<li>将<code>Makefile</code>的前三行修改一下</li>
</ul>
<img src="https://yqypicbed.oss-cn-hangzhou.aliyuncs.com/typoraoss/image-20220222141647174.png" alt="image-20220222141647174" width="300" />

<ul>
<li>和如图所示的nvcc位置（若前面配置了环境变量则无需这一步操作）</li>
</ul>
<img src="https://yqypicbed.oss-cn-hangzhou.aliyuncs.com/typoraoss/image-20220222141654527.png" alt="image-20220222141654527" width="500" />

<ul>
<li><p>修改好猴按<code>esc</code>左下角出现冒号后<code>wq</code>保存退出</p>
</li>
<li><p>在darknet路径下编译</p>
</li>
</ul>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">$ make -j4</span><br></pre></td></tr></table></figure>

<p>编译完成如图</p>
<img src="https://yqypicbed.oss-cn-hangzhou.aliyuncs.com/typoraoss/image-20220224143750683.png" alt="image-20220224143750683" width='2000' style="zoom:25%;" />

<p>在命令行下输入  <code>./darknet</code></p>
<img src="https://yqypicbed.oss-cn-hangzhou.aliyuncs.com/typoraoss/image-20220224143905042.png" alt="image-20220224143905042"  style="zoom:50%;" />

<p>在yolo官网下载yolov4和yolov4-tiny的权重文件放入文件夹</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">#Yolov4图片的检测</span></span><br><span class="line">./darknet detect cfg/yolov4.cfg yolov4.weights data/dog.jpg <span class="comment"># 简写版</span></span><br><span class="line"></span><br><span class="line">./darknet detector <span class="built_in">test</span> cfg/coco.data cfg/yolov4.cfg yolov4.weights data/dog.jpg <span class="comment"># 完整版</span></span><br><span class="line"></span><br><span class="line"></span><br><span class="line"><span class="comment">#Yolov4-tiny图片的检测</span></span><br><span class="line">./darknet detect cfg/yolov4-tiny.cfg yolov4-tiny.weights data/dog.jpg <span class="comment"># 简写版</span></span><br><span class="line"></span><br><span class="line">./darknet detector <span class="built_in">test</span> cfg/coco.data cfg/yolov4-tiny.cfg yolov4-tiny.weights data/dog.jpg <span class="comment"># 完整版</span></span><br><span class="line"></span><br><span class="line"></span><br><span class="line"><span class="comment"># 改变检测阈值</span></span><br><span class="line"><span class="comment"># 默认情况下，YOLO仅显示检测到的置信度为.25或更高的对象。您可以通过将-thresh标志传递给yolo命令来更改此设置。</span></span><br><span class="line"></span><br><span class="line"><span class="comment">#例如，要显示所有检测，您可以将阈值设置为0.1：</span></span><br><span class="line">./darknet detect cfg/yolov4-tiny.cfg yolov4-tiny.weights data/dog.jpg -thresh 0.1</span><br><span class="line"></span><br></pre></td></tr></table></figure>

<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">#Yolov4摄像头实时检测方法：</span></span><br><span class="line">./darknet detector demo cfg/coco.data cfg/yolov4.cfg yolov4.weights /dev/video1</span><br><span class="line"></span><br><span class="line"><span class="comment">#Yolov4-tiny摄像头实时检测方法：</span></span><br><span class="line">./darknet detector demo cfg/coco.data cfg/yolov4-tiny.cfg yolov4-tiny.weights /dev/video1</span><br><span class="line"></span><br></pre></td></tr></table></figure>



<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">#Yolov4视频的检测(github下来的data里面并没有该视频文件，需要用户自行上传要检测的视频文件到data文件夹下)</span></span><br><span class="line">./darknet detector demo cfg/coco.data cfg/yolov4.cfg yolov4.weights data/123.mp4</span><br><span class="line"></span><br><span class="line"><span class="comment">#Yolov4-tiny视频的检测</span></span><br><span class="line"><span class="comment">#Yolov4-tiny视频的检测(github下来的data里面并没有该视频文件，需要用户自行上传要检测的视频文件到data文件夹下)</span></span><br><span class="line"></span><br><span class="line">./darknet detector demo cfg/coco.data cfg/yolov4-tiny.cfg yolov4-tiny.weights data/xxx.mp4</span><br><span class="line"></span><br></pre></td></tr></table></figure>

<ul>
<li>若要调用csi摄像头需要gstream的支持</li>
</ul>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">./darknet detector demo cfg/coco.data cfg/yolov4-tiny.cfg yolov4-tiny.weights <span class="string">&quot;nvarguscamerasrc ! video/x-raw(memory:NVMM), width=1280, height=720, format=NV12, framerate=30/1 ! nvvidconv  ! video/x-raw, width=1280, height=720, format=BGRx ! videoconvert ! video/x-raw, format=BGR ! appsink&quot;</span></span><br><span class="line"></span><br></pre></td></tr></table></figure>



<p><a target="_blank" rel="noopener" href="https://blog.csdn.net/qq_44360908/article/details/122777848"> 解决Jetson Nano使用CSI摄像头在Darknet下实时检测绿屏_</a></p>
<h1 id="Nvidia-Jetson-Nano-安装-GStreamer"><a href="#Nvidia-Jetson-Nano-安装-GStreamer" class="headerlink" title="Nvidia Jetson Nano 安装 GStreamer"></a>Nvidia Jetson Nano 安装 GStreamer</h1><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line">sudo add-apt-repository universe</span><br><span class="line">sudo add-apt-repository multiverse</span><br><span class="line">sudo apt-get update</span><br><span class="line">sudo apt-get install gstreamer1.0-tools gstreamer1.0-alsa gstreamer1.0-plugins-base gstreamer1.0-plugins-good gstreamer1.0-plugins-bad gstreamer1.0-plugins-ugly gstreamer1.0-libav</span><br><span class="line">sudo apt-get install libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev libgstreamer-plugins-good1.0-dev libgstreamer-plugins-bad1.0-dev</span><br></pre></td></tr></table></figure>



<h2 id="1-配置GStreamer管道"><a href="#1-配置GStreamer管道" class="headerlink" title="1. 配置GStreamer管道"></a>1. 配置GStreamer管道</h2><p>首先说一下思路：由于yolov3本身不支持csi摄像头，因此需要通过GStreamer来对csi摄像头获取的视频进行预处理，然后提交给yolov3进行识别判定，而这一过程重点就是GStreamer管道的配置，以下是博主的管道配置</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment"># 仅适用于jetson-nano运行yolov4-tiny demo。注意请在darknet的文档页下打开terminal输入</span></span><br><span class="line"></span><br><span class="line">./darknet detector demo cfg/coco.data cfg/yolov4-tiny.cfg yolov4-tiny.weights <span class="string">&quot;nvarguscamerasrc ! video/x-raw(memory:NVMM), width=1280, height=720, format=NV12, framerate=30/1 ! nvvidconv flip-method=2 ! video/x-raw, width=1280, height=720, format=BGRx ! videoconvert ! video/x-raw, format=BGR ! appsink&quot;</span></span><br><span class="line"></span><br><span class="line"></span><br><span class="line">./darknet detector demo cfg/coco.data cfg/yolov4-tiny.cfg yolov4-tiny.weights <span class="string">&quot;nvarguscamerasrc ! video/x-raw(memory:NVMM), width=1280, height=720, format=NV12, framerate=30/1 ! nvvidconv flip-method=2 ! video/x-raw, width=1280, height=720, format=BGRx ! videoconvert ! video/x-raw, format=BGR ! appsink&quot;</span></span><br><span class="line"></span><br></pre></td></tr></table></figure>





<p>原版：</p>
<p>.&#x2F;darknet detector demo ok&#x2F;new.data ok&#x2F;yolov4-tiny-new.cfg ok&#x2F;yolov4-tiny-new_last.weights “nvarguscamerasrc ! video&#x2F;x-raw(memory:NVMM), width&#x3D;1280, height&#x3D;720, format&#x3D;NV12, framerate&#x3D;30&#x2F;1 ! nvvidconv flip-method&#x3D;2 ! video&#x2F;x-raw, width&#x3D;1280, height&#x3D;720, format&#x3D;BGRx ! videoconvert ! video&#x2F;x-raw, format&#x3D;BGR ! appsink”</p>
<p>口罩</p>
<p>.&#x2F;darknet detector demo cfg&#x2F;obj.data cfg&#x2F;yolov4-tiny-masks.cfg yolov4-tiny-obj_last.weights “nvarguscamerasrc ! video&#x2F;x-raw(memory:NVMM), width&#x3D;1280, height&#x3D;720, format&#x3D;NV12, framerate&#x3D;30&#x2F;1 ! nvvidconv flip-method&#x3D;2 ! video&#x2F;x-raw, width&#x3D;1280, height&#x3D;720, format&#x3D;BGRx ! videoconvert ! video&#x2F;x-raw, format&#x3D;BGR ! appsink”</p>
<p>yolo:</p>
<p>.&#x2F;darknet detector demo cfg&#x2F;coco.data cfg&#x2F;yolov4-tiny.cfg yolov4-tiny.weights “nvarguscamerasrc ! video&#x2F;x-raw(memory:NVMM), width&#x3D;1280, height&#x3D;720, format&#x3D;NV12, framerate&#x3D;30&#x2F;1 ! nvvidconv flip-method&#x3D;2 ! video&#x2F;x-raw, width&#x3D;1280, height&#x3D;720, format&#x3D;BGRx ! videoconvert ! video&#x2F;x-raw, format&#x3D;BGR ! appsink”</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line">sudo add-apt-repository universe</span><br><span class="line">sudo add-apt-repository multiverse</span><br><span class="line">sudo apt-get update</span><br><span class="line">sudo apt-get install gstreamer1.0-tools gstreamer1.0-alsa gstreamer1.0-plugins-base gstreamer1.0-plugins-good gstreamer1.0-plugins-bad gstreamer1.0-plugins-ugly gstreamer1.0-libav</span><br><span class="line">sudo apt-get install libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev libgstreamer-plugins-good1.0-dev libgstreamer-plugins-bad1.0-dev</span><br></pre></td></tr></table></figure>

<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br></pre></td><td class="code"><pre><span class="line">官方：</span><br><span class="line">./darknet detector demo ok/new.data ok/yolov4-tiny-new.cfg ok/yolov4-tiny-new_last.weights <span class="string">&quot;nvarguscamerasrc ! video/x-raw(memory:NVMM), width=1280, height=720, format=NV12, framerate=30/1 ! nvvidconv flip-method=2 ! video/x-raw, width=1280, height=720, format=BGRx ! videoconvert ! video/x-raw, format=BGR ! appsink&quot;</span></span><br><span class="line"></span><br><span class="line">// 仅适用于jetson-nano运行yolov3-tiny demo。注意请在darknet的文档页下打开terminal输入</span><br><span class="line">./darknet detector demo cfg/coco.data cfg/yolov4-tiny.cfg yolov4-tiny.weights <span class="string">&quot;nvarguscamerasrc ! video/x-raw(memory:NVMM), width=1280, height=720, format=NV12, framerate=30/1 ! nvvidconv flip-method=2 ! video/x-raw, width=1280, height=720, format=BGRx ! videoconvert ! video/x-raw, format=BGR ! appsink&quot;</span></span><br><span class="line"></span><br><span class="line"></span><br><span class="line">./darknet detector demo cfg/coco.data cfg/yolov4-tiny.cfg yolov4-tiny.weights <span class="string">&quot;nvarguscamerasrc ! video/x-raw(memory:NVMM), width=1280, height=720, format=NV12, framerate=30/1 ! nvvidconv flip-method=2 ! video/x-raw, width=1280, height=720, format=BGRx ! videoconvert ! video/x-raw, format=BGR ! appsink&quot;</span></span><br><span class="line"></span><br><span class="line"></span><br><span class="line">./darknet detector demo cfg/coco.data cfg/yolov4-tiny.cfg yolov4-tiny.weights <span class="string">&quot;nvarguscamerasrc ! video/x-raw(memory:NVMM), width=1280, height=720, format=NV12, framerate=30/1 ! nvvidconv flip-method=2 ! video/x-raw, width=1280, height=720, format=BGRx ! videoconvert ! video/x-raw, format=BGR ! appsink&quot;</span></span><br></pre></td></tr></table></figure>






                
            </div>
            <hr/>

            

    <div class="reprint" id="reprint-statement">
        
            <div class="reprint__author">
                <span class="reprint-meta" style="font-weight: bold;">
                    <i class="fas fa-user">
                        Author:
                    </i>
                </span>
                <span class="reprint-info">
                    <a href="/about" rel="external nofollow noreferrer">yinqiyu</a>
                </span>
            </div>
            <div class="reprint__type">
                <span class="reprint-meta" style="font-weight: bold;">
                    <i class="fas fa-link">
                        Link:
                    </i>
                </span>
                <span class="reprint-info">
                    <a href="http://example.com/2024/02/13/1.%20EnvironmentConfiguration/">http://example.com/2024/02/13/1.%20EnvironmentConfiguration/</a>
                </span>
            </div>
            <div class="reprint__notice">
                <span class="reprint-meta" style="font-weight: bold;">
                    <i class="fas fa-copyright">
                        Reprint policy:
                    </i>
                </span>
                <span class="reprint-info">
                    All articles in this blog are used except for special statements
                    <a href="https://creativecommons.org/licenses/by/4.0/deed.zh" rel="external nofollow noreferrer" target="_blank">CC BY 4.0</a>
                    reprint policy. If reproduced, please indicate source
                    <a href="/about" target="_blank">yinqiyu</a>
                    !
                </span>
            </div>
        
    </div>

    <script async defer>
      document.addEventListener("copy", function (e) {
        let toastHTML = '<span>Copied successfully, please follow the reprint policy of this article</span><button class="btn-flat toast-action" onclick="navToReprintStatement()" style="font-size: smaller">more</a>';
        M.toast({html: toastHTML})
      });

      function navToReprintStatement() {
        $("html, body").animate({scrollTop: $("#reprint-statement").offset().top - 80}, 800);
      }
    </script>



            <div class="tag_share" style="display: block;">
                <div class="post-meta__tag-list" style="display: inline-block;">
                    
                        <div class="article-tag">
                            <span class="chip bg-color">No tag</span>
                        </div>
                    
                </div>
                <div class="post_share" style="zoom: 80%; width: fit-content; display: inline-block; float: right; margin: -0.15rem 0;">
                    <link rel="stylesheet" type="text/css" href="/libs/share/css/share.min.css">
<div id="article-share">

    
    <div class="social-share" data-sites="twitter,facebook,google,qq,qzone,wechat,weibo,douban,linkedin" data-wechat-qrcode-helper="<p>微信扫一扫即可分享！</p>"></div>
    <script src="/libs/share/js/social-share.min.js"></script>
    

    

</div>

                </div>
            </div>
            
                <div id="reward">
    <a href="#rewardModal" class="reward-link modal-trigger btn-floating btn-medium waves-effect waves-light red">赏</a>

    <!-- Modal Structure -->
    <div id="rewardModal" class="modal">
        <div class="modal-content">
            <a class="close modal-close"><i class="fas fa-times"></i></a>
            <h4 class="reward-title">你的赏识是我前进的动力</h4>
            <div class="reward-content">
                <div class="reward-tabs">
                    <ul class="tabs row">
                        <li class="tab col s6 alipay-tab waves-effect waves-light"><a href="#alipay">支付宝</a></li>
                        <li class="tab col s6 wechat-tab waves-effect waves-light"><a href="#wechat">微 信</a></li>
                    </ul>
                    <div id="alipay">
                        <img src="/medias/reward/alipay.jpg" class="reward-img" alt="支付宝打赏二维码">
                    </div>
                    <div id="wechat">
                        <img src="/medias/reward/wechat.png" class="reward-img" alt="微信打赏二维码">
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

<script>
    $(function () {
        $('.tabs').tabs();
    });
</script>

            
        </div>
    </div>

    

    

    

    

    

    

    

    

    

<article id="prenext-posts" class="prev-next articles">
    <div class="row article-row">
        
        <div class="article col s12 m6" data-aos="fade-up">
            <div class="article-badge left-badge text-color">
                <i class="fas fa-chevron-left"></i>&nbsp;Previous</div>
            <div class="card">
                <a href="/2024/02/13/2.%20yolov5-tensorrt-deepstream/">
                    <div class="card-image">
                        
                        
                        <img src="/medias/featureimages/21.jpg" class="responsive-img" alt="2.yolov5+tensorrt+deepstream">
                        
                        <span class="card-title">2.yolov5+tensorrt+deepstream</span>
                    </div>
                </a>
                <div class="card-content article-content">
                    <div class="summary block-with-text">
                        
                            
                        
                    </div>
                    <div class="publish-info">
                        <span class="publish-date">
                            <i class="far fa-clock fa-fw icon-date"></i>2024-02-13
                        </span>
                        <span class="publish-author">
                            
                            <i class="fas fa-user fa-fw"></i>
                            yinqiyu
                            
                        </span>
                    </div>
                </div>
                
            </div>
        </div>
        
        
        <div class="article col s12 m6" data-aos="fade-up">
            <div class="article-badge right-badge text-color">
                Next&nbsp;<i class="fas fa-chevron-right"></i>
            </div>
            <div class="card">
                <a href="/2024/02/13/hello-world/">
                    <div class="card-image">
                        
                        
                        <img src="/medias/featureimages/12.jpg" class="responsive-img" alt="Hello World">
                        
                        <span class="card-title">Hello World</span>
                    </div>
                </a>
                <div class="card-content article-content">
                    <div class="summary block-with-text">
                        
                            
                        
                    </div>
                    <div class="publish-info">
                            <span class="publish-date">
                                <i class="far fa-clock fa-fw icon-date"></i>2024-02-13
                            </span>
                        <span class="publish-author">
                            
                            <i class="fas fa-user fa-fw"></i>
                            yinqiyu
                            
                        </span>
                    </div>
                </div>
                
            </div>
        </div>
        
    </div>
</article>

</div>



<!-- 代码块功能依赖 -->
<script type="text/javascript" src="/libs/codeBlock/codeBlockFuction.js"></script>



<!-- 代码语言 -->

<script type="text/javascript" src="/libs/codeBlock/codeLang.js"></script>


<!-- 代码块复制 -->

<script type="text/javascript" src="/libs/codeBlock/codeCopy.js"></script>


<!-- 代码块收缩 -->

<script type="text/javascript" src="/libs/codeBlock/codeShrink.js"></script>



    </div>
    <div id="toc-aside" class="expanded col l3 hide-on-med-and-down">
        <div class="toc-widget card" style="background-color: white;">
            <div class="toc-title"><i class="far fa-list-alt"></i>&nbsp;&nbsp;TOC</div>
            <div id="toc-content"></div>
        </div>
    </div>
</div>

<!-- TOC 悬浮按钮. -->

<div id="floating-toc-btn" class="hide-on-med-and-down">
    <a class="btn-floating btn-large bg-color">
        <i class="fas fa-list-ul"></i>
    </a>
</div>


<script src="/libs/tocbot/tocbot.min.js"></script>
<script>
    $(function () {
        tocbot.init({
            tocSelector: '#toc-content',
            contentSelector: '#articleContent',
            headingsOffset: -($(window).height() * 0.4 - 45),
            collapseDepth: Number('0'),
            headingSelector: 'h2, h3, h4'
        });

        // Set scroll toc fixed.
        let tocHeight = parseInt($(window).height() * 0.4 - 64);
        let $tocWidget = $('.toc-widget');
        $(window).scroll(function () {
            let scroll = $(window).scrollTop();
            /* add post toc fixed. */
            if (scroll > tocHeight) {
                $tocWidget.addClass('toc-fixed');
            } else {
                $tocWidget.removeClass('toc-fixed');
            }
        });

        
        /* 修复文章卡片 div 的宽度. */
        let fixPostCardWidth = function (srcId, targetId) {
            let srcDiv = $('#' + srcId);
            if (srcDiv.length === 0) {
                return;
            }

            let w = srcDiv.width();
            if (w >= 450) {
                w = w + 21;
            } else if (w >= 350 && w < 450) {
                w = w + 18;
            } else if (w >= 300 && w < 350) {
                w = w + 16;
            } else {
                w = w + 14;
            }
            $('#' + targetId).width(w);
        };

        // 切换TOC目录展开收缩的相关操作.
        const expandedClass = 'expanded';
        let $tocAside = $('#toc-aside');
        let $mainContent = $('#main-content');
        $('#floating-toc-btn .btn-floating').click(function () {
            if ($tocAside.hasClass(expandedClass)) {
                $tocAside.removeClass(expandedClass).hide();
                $mainContent.removeClass('l9');
            } else {
                $tocAside.addClass(expandedClass).show();
                $mainContent.addClass('l9');
            }
            fixPostCardWidth('artDetail', 'prenext-posts');
        });
        
    });
</script>

    

</main>




    <footer class="page-footer bg-color">
    
        <link rel="stylesheet" href="/libs/aplayer/APlayer.min.css">
<style>
    .aplayer .aplayer-lrc p {
        
        display: none;
        
        font-size: 12px;
        font-weight: 700;
        line-height: 16px !important;
    }

    .aplayer .aplayer-lrc p.aplayer-lrc-current {
        
        display: none;
        
        font-size: 15px;
        color: #42b983;
    }

    
    .aplayer.aplayer-fixed.aplayer-narrow .aplayer-body {
        left: -66px !important;
    }

    .aplayer.aplayer-fixed.aplayer-narrow .aplayer-body:hover {
        left: 0px !important;
    }

    
</style>
<div class="">
    
    <div class="row">
        <meting-js class="col l8 offset-l2 m10 offset-m1 s12"
                   server="netease"
                   type="playlist"
                   id="503838841"
                   fixed='true'
                   autoplay='false'
                   theme='#42b983'
                   loop='all'
                   order='random'
                   preload='auto'
                   volume='0.7'
                   list-folded='true'
        >
        </meting-js>
    </div>
</div>

<script src="/libs/aplayer/APlayer.min.js"></script>
<script src="/libs/aplayer/Meting.min.js"></script>

    

    <div class="container row center-align"
         style="margin-bottom: 0px !important;">
        <div class="col s12 m8 l8 copy-right">
            Copyright&nbsp;&copy;
            
                <span id="year">2019-2024</span>
            
            <a href="/about" target="_blank">yinqiyu</a>
            |&nbsp;Powered by&nbsp;<a href="https://hexo.io/" target="_blank">Hexo</a>
            |&nbsp;Theme&nbsp;<a href="https://github.com/blinkfox/hexo-theme-matery" target="_blank">Matery</a>
            
            <br>
            
            
            
                
            
            
                <span id="busuanzi_container_site_pv">
                &nbsp;|&nbsp;<i class="far fa-eye"></i>&nbsp;Total visits:&nbsp;
                    <span id="busuanzi_value_site_pv" class="white-color"></span>
            </span>
            
            
                <span id="busuanzi_container_site_uv">
                &nbsp;|&nbsp;<i class="fas fa-users"></i>&nbsp;Total visitors:&nbsp;
                    <span id="busuanzi_value_site_uv" class="white-color"></span>
            </span>
            
            <br>

            <!-- 运行天数提醒. -->
            
            <br>
            
        </div>
        <div class="col s12 m4 l4 social-link social-statis">
    <a href="https://github.com/blinkfox" class="tooltipped" target="_blank" data-tooltip="访问我的GitHub" data-position="top" data-delay="50">
        <i class="fab fa-github"></i>
    </a>



    <a href="mailto:1181062873@qq.com" class="tooltipped" target="_blank" data-tooltip="邮件联系我" data-position="top" data-delay="50">
        <i class="fas fa-envelope-open"></i>
    </a>







    <a href="tencent://AddContact/?fromId=50&fromSubId=1&subcmd=all&uin=1181062873" class="tooltipped" target="_blank" data-tooltip="QQ联系我: 1181062873" data-position="top" data-delay="50">
        <i class="fab fa-qq"></i>
    </a>







    <a href="/atom.xml" class="tooltipped" target="_blank" data-tooltip="RSS 订阅" data-position="top" data-delay="50">
        <i class="fas fa-rss"></i>
    </a>

</div>
    </div>
</footer>

<div class="progress-bar"></div>


    <!-- 搜索遮罩框 -->
<div id="searchModal" class="modal">
    <div class="modal-content">
        <div class="search-header">
            <span class="title"><i class="fas fa-search"></i>&nbsp;&nbsp;Search</span>
            <input type="search" id="searchInput" name="s" placeholder="Please enter a search keyword"
                   class="search-input">
        </div>
        <div id="searchResult"></div>
    </div>
</div>

<script type="text/javascript">
$(function () {
    var searchFunc = function (path, search_id, content_id) {
        'use strict';
        $.ajax({
            url: path,
            dataType: "xml",
            success: function (xmlResponse) {
                // get the contents from search data
                var datas = $("entry", xmlResponse).map(function () {
                    return {
                        title: $("title", this).text(),
                        content: $("content", this).text(),
                        url: $("url", this).text()
                    };
                }).get();
                var $input = document.getElementById(search_id);
                var $resultContent = document.getElementById(content_id);
                $input.addEventListener('input', function () {
                    var str = '<ul class=\"search-result-list\">';
                    var keywords = this.value.trim().toLowerCase().split(/[\s\-]+/);
                    $resultContent.innerHTML = "";
                    if (this.value.trim().length <= 0) {
                        return;
                    }
                    // perform local searching
                    datas.forEach(function (data) {
                        var isMatch = true;
                        var data_title = data.title.trim().toLowerCase();
                        var data_content = data.content.trim().replace(/<[^>]+>/g, "").toLowerCase();
                        var data_url = data.url;
                        data_url = data_url.indexOf('/') === 0 ? data.url : '/' + data_url;
                        var index_title = -1;
                        var index_content = -1;
                        var first_occur = -1;
                        // only match artiles with not empty titles and contents
                        if (data_title !== '' && data_content !== '') {
                            keywords.forEach(function (keyword, i) {
                                index_title = data_title.indexOf(keyword);
                                index_content = data_content.indexOf(keyword);
                                if (index_title < 0 && index_content < 0) {
                                    isMatch = false;
                                } else {
                                    if (index_content < 0) {
                                        index_content = 0;
                                    }
                                    if (i === 0) {
                                        first_occur = index_content;
                                    }
                                }
                            });
                        }
                        // show search results
                        if (isMatch) {
                            str += "<li><a href='" + data_url + "' class='search-result-title'>" + data_title + "</a>";
                            var content = data.content.trim().replace(/<[^>]+>/g, "");
                            if (first_occur >= 0) {
                                // cut out 100 characters
                                var start = first_occur - 20;
                                var end = first_occur + 80;
                                if (start < 0) {
                                    start = 0;
                                }
                                if (start === 0) {
                                    end = 100;
                                }
                                if (end > content.length) {
                                    end = content.length;
                                }
                                var match_content = content.substr(start, end);
                                // highlight all keywords
                                keywords.forEach(function (keyword) {
                                    var regS = new RegExp(keyword, "gi");
                                    match_content = match_content.replace(regS, "<em class=\"search-keyword\">" + keyword + "</em>");
                                });

                                str += "<p class=\"search-result\">" + match_content + "...</p>"
                            }
                            str += "</li>";
                        }
                    });
                    str += "</ul>";
                    $resultContent.innerHTML = str;
                });
            }
        });
    };

    searchFunc('/search.xml', 'searchInput', 'searchResult');
});
</script>

    <!-- 白天和黑夜主题 -->
<div class="stars-con">
    <div id="stars"></div>
    <div id="stars2"></div>
    <div id="stars3"></div>  
</div>

<script>
    function switchNightMode() {
        $('<div class="Cuteen_DarkSky"><div class="Cuteen_DarkPlanet"></div></div>').appendTo($('body')),
        setTimeout(function () {
            $('body').hasClass('DarkMode') 
            ? ($('body').removeClass('DarkMode'), localStorage.setItem('isDark', '0'), $('#sum-moon-icon').removeClass("fa-sun").addClass('fa-moon')) 
            : ($('body').addClass('DarkMode'), localStorage.setItem('isDark', '1'), $('#sum-moon-icon').addClass("fa-sun").removeClass('fa-moon')),
            
            setTimeout(function () {
            $('.Cuteen_DarkSky').fadeOut(1e3, function () {
                $(this).remove()
            })
            }, 2e3)
        })
    }
</script>

    <!-- 回到顶部按钮 -->
<div id="backTop" class="top-scroll">
    <a class="btn-floating btn-large waves-effect waves-light" href="#!">
        <i class="fas fa-arrow-up"></i>
    </a>
</div>


    <script src="/libs/materialize/materialize.min.js"></script>
    <script src="/libs/masonry/masonry.pkgd.min.js"></script>
    <script src="/libs/aos/aos.js"></script>
    <script src="/libs/scrollprogress/scrollProgress.min.js"></script>
    <script src="/libs/lightGallery/js/lightgallery-all.min.js"></script>
    <script src="/js/matery.js"></script>

    

    
    
    

    <!-- 雪花特效 -->
    

    <!-- 鼠标星星特效 -->
    

     
        <script src="https://ssl.captcha.qq.com/TCaptcha.js"></script>
        <script src="/libs/others/TencentCaptcha.js"></script>
        <button id="TencentCaptcha" data-appid="xxxxxxxxxx" data-cbfn="callback" type="button" hidden></button>
    

    <!-- Baidu Analytics -->

    <!-- Baidu Push -->

<script>
    (function () {
        var bp = document.createElement('script');
        var curProtocol = window.location.protocol.split(':')[0];
        if (curProtocol === 'https') {
            bp.src = 'https://zz.bdstatic.com/linksubmit/push.js';
        } else {
            bp.src = 'http://push.zhanzhang.baidu.com/push.js';
        }
        var s = document.getElementsByTagName("script")[0];
        s.parentNode.insertBefore(bp, s);
    })();
</script>

    
    <script src="/libs/others/clicklove.js" async="async"></script>
    
    
    <script async src="/libs/others/busuanzi.pure.mini.js"></script>
    

    

    

    <!--腾讯兔小巢-->
    
    

    

    

    
    <script src="/libs/instantpage/instantpage.js" type="module"></script>
    

</body>

</html>
